<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\web\View;
use kartik\date\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\ActivityModel */
/* @var $form yii\widgets\ActiveForm */
$url=\Yii::getAlias('@web');
$js3=<<< Js
function myAjax(){
		var x=$("#activitymodel-stu_id").val();
		$.ajax({
                    url: '$url/personinfo/getname?stuid='+x,
                    type: 'get',
                    dataType: 'text',
                    success: function (data) {
                       $("#activitymodel-name").val(data);
                    }
                });
}
Js;
$this->registerJs($js3, View::POS_END, 'myAjax1');
?>

<div class="activity-model-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'stu_id')->textInput(['maxlength' => true,
    		'onblur'=>'myAjax()',
    ]) ?>
    <?= $form->field($model, 'name')->textInput(['maxlength' => true,
    		'readonly'=>true,
    ]) ?>

    <?= $form->field($model, 'year')->dropDownList([(date('Y').'-'.(date('Y')+1))=>(date('Y').'-'.(date('Y')+1)),
    																						((date('Y')-1).'-'.date('Y'))=>((date('Y')-1).'-'.date('Y')),
    																						((date('Y')-2).'-'.(date('Y')-1))=>((date('Y')-2).'-'.(date('Y')-1)),
    																							((date('Y')-3).'-'.(date('Y')-2))=>((date('Y')-3).'-'.(date('Y')-2))])
    																								->label('学年')	 ?>

    <?= $form->field($model, 'semester')->dropDownList(['1'=>'1','2'=>'2']) ?>

   <?= $form->field($model, 'date')->widget(DatePicker::classname(), [
       'options' => ['placeholder' => 'Enter birth date ...'],
       'pluginOptions' => [
           'autoclose'=>true,
           'format' => 'yyyy.mm.dd'
       ]
   ])->label('日期');?>

    <?= $form->field($model, 'time')->textInput(['maxlength' => true])->label('时间（如：9:20-14:20）') ?>

    <?= $form->field($model, 'activity')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'type')->dropDownList(['缺勤'=>'缺勤','迟到'=>'迟到','早退'=>'早退']) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? '添加' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
